home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / m_to_r / rtga / testunit.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  3.3 KB  |  147 lines

  1. {  Tomasz Stanczak                                                   }
  2. {  Hardenbergstr. 8                                                  }
  3. {  31275 Lehrte                                                      }
  4. {  Germany                                                           }
  5. {                                                                    }
  6. {  CIS ID: 100735,3273                                               }
  7.  
  8. unit TestUnit;
  9.  
  10. interface
  11.  
  12. uses
  13.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  14.   Forms, Dialogs, RtGauge, StdCtrls, ExtCtrls, Gauges,
  15.   VBXCtrl, Bigauge;
  16.  
  17. type
  18.   TForm1 = class(TForm)
  19.     RtGauge1: TRtGauge;
  20.     Button1: TButton;
  21.     Gauge1: TGauge;
  22.     Button2: TButton;
  23.     BiGauge1: TBiGauge;
  24.     Button3: TButton;
  25.     Label1: TLabel;
  26.     Label2: TLabel;
  27.     Label3: TLabel;
  28.     Label4: TLabel;
  29.     Edit1: TEdit;
  30.     procedure Button1Click(Sender: TObject);
  31.     procedure Button2Click(Sender: TObject);
  32.     procedure Button3Click(Sender: TObject);
  33.   private
  34.     { Private-Deklarationen }
  35.     InLoop1,InLoop2,InLoop3: Boolean;
  36.   public
  37.     { Public-Deklarationen }
  38.   end;
  39.  
  40. var
  41.   Form1: TForm1;
  42.  
  43. implementation
  44.  
  45. {$R *.DFM}
  46.  
  47. procedure TForm1.Button1Click(Sender: TObject);
  48. var
  49.    n,Cnt: longint;
  50.    T: TDateTime;
  51.    S: string;
  52. begin
  53.    if InLoop1 then
  54.    begin
  55.       InLoop1 := False;
  56.       exit;
  57.    end;
  58.    S := Button1.Caption;
  59.    Button1.Caption := 'Stop';
  60.    InLoop1 := True;
  61.    Cnt := StrToInt(Edit1.Text);
  62.    try
  63.       T := Time;
  64.       RtGauge1.MinValue := 0;
  65.       RtGauge1.MaxValue := Cnt;
  66.       for n:=0 to Cnt do
  67.       begin
  68.          RtGauge1.Value := n;
  69.          Application.ProcessMessages;
  70.          if not InLoop1 then
  71.             abort;
  72.       end;
  73.       InLoop1 := False;
  74.    finally
  75.       Button1.Caption := S;
  76.       Label1.Caption := FormatDateTime('hh:nn:ss',Time-T);
  77.    end;
  78. end;
  79.  
  80. procedure TForm1.Button2Click(Sender: TObject);
  81. var
  82.    n,Cnt: longint;
  83.    T: TDateTime;
  84.    S: string;
  85. begin
  86.    if InLoop2 then
  87.    begin
  88.       InLoop2 := False;
  89.       exit;
  90.    end;
  91.    S := Button2.Caption;
  92.    Button2.Caption := 'Stop';
  93.    InLoop2 := True;
  94.    Cnt := StrToInt(Edit1.Text);
  95.    try
  96.       T := Time;
  97.       Gauge1.MinValue := 0;
  98.       Gauge1.MaxValue := Cnt;
  99.       for n:=0 to Cnt do
  100.       begin
  101.          Gauge1.Progress := n;
  102.          Application.ProcessMessages;
  103.          if not InLoop2 then
  104.             exit;
  105.       end;
  106.       InLoop2 := False;
  107.    finally
  108.       Button2.Caption := S;
  109.       Label2.Caption := FormatDateTime('hh:nn:ss',Time-T);
  110.    end;
  111. end;
  112.  
  113. procedure TForm1.Button3Click(Sender: TObject);
  114. var
  115.    n,Cnt: longint;
  116.    T: TDateTime;
  117.    S: string;
  118. begin
  119.    if InLoop3 then
  120.    begin
  121.       InLoop3 := False;
  122.       exit;
  123.    end;
  124.    InLoop3 := True;
  125.    S := Button3.Caption;
  126.    Button3.Caption := 'Stop';
  127.    Cnt := StrToInt(Edit1.Text);
  128.    try
  129.       T := Time;
  130.       BiGauge1.Min := 0;
  131.       BiGauge1.Max := Cnt;
  132.       for n:=0 to Cnt do
  133.       begin
  134.          BiGauge1.Value := n;
  135.          Application.ProcessMessages;
  136.          if not InLoop3 then
  137.             exit;
  138.       end;
  139.       InLoop3 := False;
  140.    finally
  141.       Button3.Caption := S;
  142.       Label3.Caption := FormatDateTime('hh:nn:ss',Time-T);
  143.    end;
  144. end;
  145.  
  146. end.
  147.